#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>


#include <iostream>
#include "SHMLogAdapterClient.h"


#define SHMSZ (4096*1024)
int main(int argc, char** argv)
{
	int shmid;
	key_t key;
	char *shm, *s;

	/*
	 * We need to get the segment named
	 * "5678", created by the server.
	 */
	key = 5678;

	/*
	 * Locate the segment.
	 */
	if ((shmid = shmget(key, SHMSZ, 0666)) < 0) {
		perror("shmget");
		return 1;
	}

	/*
	 * Now we attach the segment to our data space.
	 */
	if ((shm = (char*)shmat(shmid, NULL, 0)) == (char *) -1) {
		perror("shmat");
		return 1;
	}

	ShmLogBufHeader* p = (ShmLogBufHeader*)shm;

	U32 preCount = p->_logCount;
	while(true)
	{
		if(preCount != p->_logCount)
		{
			std::cout << "count:" << p->_logCount << " " << p->_current;
			preCount = p->_logCount;
		}
	}


	return 0;
}
